/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group2assignone.view.manager;

import group2assignone.func.UCCtoALAdapter;
import group2assignone.model.GSTax;
import group2assignone.view.OurView;
import group2assignone.ucm.manager.*;


import java.awt.GridLayout;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

/**
 *
 * @author Brad
 */
public class EditGSTView extends OurView {

    private JLabel title = new JLabel("General Sales Tax");
    private JLabel currentTaxTitle = new JLabel("Current GST: ");
    private JLabel currentTaxLabel = new JLabel();
    private JLabel enterTaxLabel = new JLabel("Enter new GST amount:");
    private JTextField taxBox = new JTextField(3);
    //JFormattedTextField taxBox = new JFormattedTextField(NumberFormat.getInstance());
    private JButton save = new JButton("Save");
    private JButton cancel = new JButton("Cancel");

    public String getInput() {
        return taxBox.getText();
    }

    @Override
    public void addComponents() {
        northPanel.add(title);
        southPanel.add(cancel);
        southPanel.add(save);

        centerPanel.setLayout(new GridLayout(2, 2, 2, 1));

        currentTaxLabel.setText("" + GSTax.getInstanceGSTax().getGST());
        centerPanel.add(currentTaxTitle);
        centerPanel.add(currentTaxLabel);
        centerPanel.add(enterTaxLabel);
        centerPanel.add(taxBox);
        centerPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
        northPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
        southPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

        setActionListeners();
        pack();
    }

    public void setActionListeners() {

        save.addActionListener(new UCCtoALAdapter(new UCEditGSTSave(this, GSTax.getInstanceGSTax())));
        cancel.addActionListener(new UCCtoALAdapter(new UCCancelAction(this)));
    }
}
